<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数参数传递方式</title>
    <script>
        //五种基本数据类型 number String boolean null undefined

        function  add(num) {
            //num局部变量
            //伪代码：var num = 10;
            var num = num + 10;
            return num;
        }
        //console.log(num);  //报错 num is not defined

        var count = 20;
        var result = add(count);
        console.log("count 的值：" + count);   //20
        console.log("result的值：" + result);  //30

        function func(num,num){
            /*
               相当于：先声明变量 var num = 1；
                       再声明变量 var num = 2；
             */
            console.log(num);   // 2
        }
        func(1,2);


        //复杂数据类型
        function  setAge(obj) {
            //var obj = person;
            obj.age = 18;
        }
        var person  = new Object();
        person.age = 20;

        setAge(person);
        console.log(person.age);    //18


        function setName(obj) {
            //var obj = person;
            obj.name = "小明";
            obj = new Object();
            obj.name = "小红";
        }

        var person = new Object();
        person.name = "小王";
        setName(person);
        console.log(person.name);  //小明
    </script>
</head>
<body>

</body>
</html>